import { defineConfig } from 'vite'
import AutoImport from 'unplugin-auto-import/vite'
import Components from 'unplugin-vue-components/vite'
import { ElementPlusResolver } from 'unplugin-vue-components/resolvers'
import { resolve } from "path"
import vue from '@vitejs/plugin-vue'

// https://vitejs.dev/config/
export default defineConfig({
  base: './',
  plugins: [vue(),
  //引入vue 插件
  AutoImport({
    imports: ["vue"],
    dts: "src/auto-import.d.ts",
  }),
  AutoImport({
    resolvers: [ElementPlusResolver()],
  }),
  Components({
    resolvers: [ElementPlusResolver()],
  })
  ],

  resolve: {
    alias: {
      "@": resolve(__dirname, "src"),
      // 注意一定不要随意命名，a b c这样的，项目的目录也不能为关键字保留字！！
      "comp": resolve(__dirname, "src/components"),
      // 配置图片要这样引用
      "/img": "./src/assets",
    }
  },

  server: {//中转服务器
    proxy: {
      '/path': {
        target:'http://8.134.151.136:9000',//这是目标地址
        // target: 'http://127.0.0.1:9000',
        changeOrigin: true,//开启代理，进行跨域
        rewrite: path => path.replace(/^\/path/, '')//设置重写路径
      }
    }
  }
})
